<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./Promise封装请求方式.js"></script>
</head>

<body>
    <button>请求</button>
        <h1></h1>
    <script>
        const h1=document.querySelector('h1')
        document.querySelector('button').addEventListener('click', async function () {
            Promise.all([
            ldgAjax({
                method: 'GET',
                url: 'http://ajax-base-api-t.itheima.net/api/getbooks'
            }),
            ldgAjax({
                method:'POST',
                url:'http://ajax-base-api-t.itheima.net/api/addboo',
                data:{bookname:'1',author:'2',publisher:'3'}
            }),
            ])
            .then(res=>{
                console.log(res);
                h1.innerHTML='我是首页'
            })
            .catch(err=>{
                console.log(err);
                h1.innerHTML=err
            })
        })
    </script>
</body>

</html>